﻿using CPPEI.Coolzon.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.Server.ServiceImplement
{
    /// <summary>
    /// 方案文件包信息
    /// </summary>
    public class SolutionPackage
    {
        /// <summary>
        /// 方案名称
        /// </summary>
        public string Name { get; set; }

        public List<SyncFile> Files { get; set; }

        public static explicit operator CPPEI.Coolzon.Server.ServiceImplement.SolutionPackage(Metadata.SolutionPackage solutionPackage)
        {
            CPPEI.Coolzon.Server.ServiceImplement.SolutionPackage retSolutionPackage = new SolutionPackage();
            retSolutionPackage.Name = solutionPackage.Name;
            retSolutionPackage.Files = new List<SyncFile>();
            foreach(var file in solutionPackage.Files)
            {
                SyncFile syncFile = new SyncFile();
                syncFile.Name = file.FileName;
                syncFile.MD5 = file.MD5;
                syncFile.Size = file.Size;

                retSolutionPackage.Files.Add(syncFile);
            }

            return retSolutionPackage;
        }
    }
}
